package com.cloud.rocketTest.mqTestController;

import com.cloud.rocketTest.entity.Order;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class MqController {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    //http://localhost:8084/create
    //http://localhost:8084/create?name=admin
    @GetMapping("/create")
    public Order create(){
        Order order = new Order(
                1,
                "张三",
                "123123",
                "软件园",
                new Date()
        );
        this.rocketMQTemplate.convertAndSend("orderTopic",order);
        return order;
    }
}
